A = input()
def check(string_A):
    st = []
    x = ["(", "[", "{"]
    y = [")", "]", "}"]
    for i in string_A:
        if i in x:
            st.append(i)
        else:
            if len(st) == 0:
                return False
            else:
               if st[-1] == x[y.index(i)]:
                    st.pop()
               else:
                   return False
    if len(st) > 0:
        return False
    return True
print(check(A)) 
